/**
 * 
 */
package it.uniroma3.dia.digraph.view;

import it.uniroma3.dia.digraph.view.interpolation.Interpolator;
import it.uniroma3.dia.digraph.view.interpolation.impl.LinearInterpolator;

import java.awt.Dimension;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JFrame;

import org.graphdrawing.graphml.xmlns.GraphType;

/**
 * @author BarycentricCoords
 *
 */
public class View extends JFrame{
	
	private static final long serialVersionUID = 3138376522287398996L;
	private DrawingPanel drawingPanel;
	private List<Interpolator> interpolators;
	
	public View(GraphType graph){
		this(graph.getDesc(), graph);
	}

	public View(String title, GraphType graph) {
		this(title, 1024, 768, graph);
	}
	
	public View(String title, int width, int height, GraphType graph){
		super(title);
		this.setPreferredSize(new Dimension(width, height));
		this.drawingPanel = new DrawingPanel();
		this.setContentPane(drawingPanel);
		this.interpolators = new LinkedList<Interpolator>();
		
		this.interpolators.add(new LinearInterpolator(drawingPanel));
		
	}
	
	
	
	

	public void update(GraphType graph){
	    
	    for (Interpolator interpolator : this.interpolators) {
		interpolator.interpolate(graph);
//		<node id="x" x="150" y="200" default="false"/>
//		<node id="y" x="250" y="490" default="false"/>
		
		
	    }
	    this.repaint();
		
	}
	
	public DrawingPanel getDrawingPanel() {
	    return this.drawingPanel;
	}
	
	public void addInterpolator(Interpolator i) {
	    this.interpolators.add(i);
	}
	
	public void setInterpolators(List<Interpolator> interpolators) {
	    this.interpolators = interpolators;
	}
	
	
	


	
	
	
	
	
	
}
